<template>
	<view class="wrapper">
		<view>
			<view class="top">
				<view class="center">
					<view class="center_top" style="align-items: center;justify-content: space-around;">
						<view><img :src="img_src" style="width: 66px; height: 66px;" alt="" /></view>
						<view>{{f0602 ? f0602 : 'peace'}}</view>
					</view>
				</view>
				<image src='https://crxqcxsz.oss-cn-beijing.aliyuncs.com/wx1.gif' mode='scaleToFill' class='gif-wave'></image>
			</view>
		</view>


		<!-- 统计 -->
		<view class="count">
			<view class="cell">{{sumday}}<text style="color: #AAAAAA;">今日token流量</text> </view>
			<view class="cell"> {{countday}} <text style="color: #AAAAAA;">今日查询次数</text> </view>
			<view class="cell"> {{f0611}} <text style="color: #AAAAAA;">剩余token量</text> </view>
			<view class="cell">{{counttoken}}<text style="color: #AAAAAA;">总查询次数</text> </view>
		</view>
		<!-- 我的订单 -->
		<view class="orders">
			<view style="display: flex; ; justify-content: space-around;">
				<view style="border: 1px solid rebeccapurple; width: 95px; height: 60px; text-align: center;line-height: 60px;background-color: lightcoral;border-radius: 20px;" @top="gotologin(e)">
					<navigator url="/pages/echarts/echarts">查询趋势</navigator> 
				</view>
				<view style="border: 1px solid rebeccapurple; width: 95px ;height: 60px;text-align: center;line-height: 60px;background-color: royalblue; border-radius: 20px;">
					<navigator url="/pages/history/history">历史查询</navigator>
				</view>
			</view>
		</view>
		<view class="address icon-arrow">
			<navigator url="/pages/name/name">个人信息</navigator> 
		</view>
		<view class="address icon-arrow">
			<navigator url="/pages/money/money">余额充值</navigator> 
		</view>
		<view class="address icon-arrow">
			<navigator url="/pages/recharge/recharge">充值记录</navigator>
		</view>
		<view class="address icon-arrow">
			<navigator url="/pages/login/login">退出登录</navigator> 
		</view>
		<!-- 其它 -->
		<view class="extra">
<!-- 			<view @click="makePhone" class="item icon-arrow">联系客服</view> -->
			<button open-type="feedback" class="item icon-arrow">意见反馈</button>
		</view>
	</view>
</template>

<script>
	// 引入vuex
	import { mapState } from 'vuex';
	import request from '../../utils/request.js'
	
	export default {
		data() {
			return {
				sumday:"",
				countday:"",
				f0611:"",
				counttoken:"",
				img_src: '',
				f0602: '',
			}
		},
		methods: {
			gotologin(e){
				uni.navigateTo({
					url:'/pages/login/login'
				})
			}
		},
		async onTabItemTap() {
		    // tab 点击时执行，此处直接接收单击事件
		    // 这里可以编写点击tabBar后的逻辑，比如刷新数据等
			uni.getStorage({
				key:'userName',
				success: (res) => {
					this.f0602 = res.data
				}
			}),
			await request.get('/wx/userinfo').then(res => {
				console.log(res.data.data);
				this.f0611 = res.data.data.f0611
				// this.f0602 = res.data.data.f0602
				this.img_src = 'http://47.121.118.149:9000/buck1/' + res.data.data.f0616
			})
			await request.get('/wx/todaytoken').then(res => {
				 this.countday = res.data.data.countday
				 this.counttoken = res.data.data.counttoken
				 this.sumday = res.data.data.sumday
			})
		  },
		mounted(){
			request.get('/wx/userinfo').then(res => {
				this.f0611 = res.data.data.f0611
				this.f0602 = res.data.data.f0602
				this.img_src = 'http://47.121.118.149:9000/buck1/' + res.data.data.f0616
			})
			request.get('/wx/todaytoken').then(res => {
				 this.countday = res.data.data.countday
				 this.counttoken = res.data.data.counttoken
				 this.sumday = res.data.data.sumday
			})
		}
	};
</script>

<style scoped lang="scss">
	Page {
		font-size: 14px;
	}

	.top {
		width: 100%;
		height: 130px;
		background: #5064eb;
		padding-top: 15px;
		position: relative;
	}

	.center {
		width: 95%;
		height: 100px;
		background: white;
		display: flex;
		flex-direction: column;
		margin: 0 auto;
		border-radius: 5px;
	}

	.center_top {
		display: flex;
		flex-direction: row;
		width: 80%;
		height: 80px;
		margin: 0 auto;
		margin-top: 20rpx;
		border-bottom: 1px solid #EEEEEE;
	}

	.center_img {
		width: 66px;
		height: 66px;
		border-radius: 50%;
		overflow: hidden;
	}

	.center_img image {
		width: 100%;
		height: 100%;
		border-radius: 50%;
	}

	.center_img .user_head {
		width: 100%;
		height: 100%;
	}

	.center_info {
		display: flex;
		flex-direction: column;
		margin-top: 20rpx;
		margin-left: 30px;
	}

	.center_name {
		font-size: 20px;
	}

	.center_phone {
		color: #BEBEBE;
	}

	// .center_down {
	// 	display: flex;
	// 	flex-direction: row;
	// 	width: 80%;
	// 	height: 35px;
	// 	margin: 0 auto;
	// 	margin-top: 20rpx;
	// }

	.center_rank {
		width: 50%;
		height: 35px;
		display: flex;
		flex-direction: row;
	}

	.rank_text {
		height: 35px;
		line-height: 35px;
		margin-left: 10rpx;
		color: #AAAAAA;
	}

	.center_vip image {
		width: 25px;
		height: 25px;
		margin-top: 15rpx;
	}

	.vip_icon {
		width: 25px;
		height: 25px;
		margin-top: -10rpx;
	}

	.vip_text {
		margin-top: -55rpx;
		margin-left: 50rpx;
		color: #AAAAAA;
	}

	.center_rank image {
		width: 35px;
		height: 35px;
	}

	.center_score {
		width: 50%;
		height: 35px;
		display: flex;
		flex-direction: row;
	}

	.center_score image {
		width: 35px;
		height: 35px;
	}

	.gif-wave {
		position: absolute;
		width: 100%;
		bottom: 0;
		left: 0;
		z-index: 99;
		mix-blend-mode: screen;
		height: 100rpx;
	}

	.wrapper {
		position: absolute;
		top: 0;
		bottom: 0;

		width: 100%;
		background-color: #F4F4F4;
	}

	.profile {
		height: 375rpx;
		background-color: #ea4451;
		display: flex;
		justify-content: center;
		align-items: center;

		.meta {
			.avatar {
				display: block;
				width: 140rpx;
				height: 140rpx;
				border-radius: 50%;
				border: 2rpx solid #fff;
				overflow: hidden;
			}

			.nickname {
				display: block;
				text-align: center;
				margin-top: 20rpx;
				font-size: 30rpx;
				color: #fff;
			}
		}
	}

	.count {
		display: flex;
		margin: 0 20rpx;
		height: 120rpx;
		text-align: center;
		border-radius: 4rpx;
		background-color: #fff;

		position: relative;
		top: 10rpx;

		.cell {
			margin-top: 10rpx;
			flex: 1;
			padding-top: 20rpx;
			font-size: 27rpx;
			color: #333;
		}

		text {
			display: block;
			font-size: 24rpx;
		}
	}

	.orders {
		margin: 20rpx 20rpx 0 20rpx;
		padding: 40rpx 0;
		background-color: #fff;
		border-radius: 4rpx;

		.title {
			padding-left: 20rpx;
			font-size: 30rpx;
			color: #333;
			padding-bottom: 20rpx;
			border-bottom: 1rpx solid #eee;
			margin-top: -30rpx;
		}

		.sorts {
			padding-top: 30rpx;
			text-align: center;
			display: flex;
		}

		[class*="icon-"] {
			flex: 1;
			font-size: 24rpx;

			&::before {
				display: block;
				font-size: 48rpx;
				margin-bottom: 8rpx;
				color: #ea4451;
			}
		}
	}

	.address {
		line-height: 1;
		background-color: #fff;
		font-size: 30rpx;
		padding: 25rpx 0 25rpx 20rpx;
		margin: 10rpx 20rpx;
		color: #333;
		border-radius: 4rpx;
	}

	.extra {
		margin: 0 20rpx;
		background-color: #fff;
		border-radius: 4rpx;

		.item {
			line-height: 1;
			padding: 25rpx 0 25rpx 20rpx;
			border-bottom: 1rpx solid #eee;
			font-size: 30rpx;
			color: #333;
		}

		button {
			text-align: left;
			background-color: #fff;

			&::after {
				border: none;
				border-radius: 0;
			}
		}
	}

	.icon-arrow {
		position: relative;

		&::before {
			position: absolute;
			top: 50%;
			right: 20rpx;
			transform: translateY(-50%);
		}
	}
</style>

